﻿using CubicFWNet.Common;
/*******************************************************************************
 * Copyright © 2016-2020 北京网非科技有限公司 版权所有
 * Author: 北京网非科技有限公司
 * Description: 网非快速开发平台NET
 * Website：http://www.wfdot.com
*********************************************************************************/
using CubicFWNet.Data.SystemManage;
using CubicFWNet.Data.SystemManage.Model;
using CubicFWNet.Data.SystemSecurity;
using CubicFWNet.Data.SystemSecurity.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CubicFWNet.Application.SystemSecurity
{
    public class OperatorLogApp
    {
        private readonly OperatorLogRepository _repository = new OperatorLogRepository();

        public IEnumerable<OperatorLog> GetItems()
        {
            return _repository.IQueryable().OrderByDescending(a => a.Time);
        }
        public OperatorLog GetOperatorLog(Guid id)
        {
            return _repository.FindEntity(id);
        }

        public ResponseResult Delete(Guid id)
        {
            var del = _repository.FindEntity(id);
            if (del == null)
                return new ResponseResult { Status = ResultType.error.ToString(), Message = "未找到该数据", Data = id };
            _repository.Delete(u => u.Id == id);
            return new ResponseResult { Status = ResultType.success.ToString(), Data = id };
        }
        public int Add(OperatorLog log)
        {
            return _repository.Insert(log);
        }

    }
}
